<?php
getDB();
class user_ffvData extends DBData
{
    public $tablename ;
    public function __construct()
    {
        $this->tablename = 'user_ffv';
        DBData::$tableName = $this->tablename;
    }
    
    public function getInfo($uid,$today)
    {
        $where = ['uid'=>$uid,'today'=>$today];
        $arrInfo = $this->Record("*",$where,$this->tablename);
        if(!$arrInfo)
        {
            $arrInfo = ["ffv_consume"=>0,'ffv'=>-0.19,'today'=>$today,'uid'=>$uid];
            $reid = $this->intotable($arrInfo,$this->tablename,1);
            $arrInfo['id'] = $reid;
        }
        return $arrInfo;
    }
    public function addconsumeffv($Info,$consume)
    {
        $Info['ffv_consume'] = (float)bcadd($Info['ffv_consume'],$consume,3);
        $number = $this->calcffv($consume);
        $Info['ffv'] = bcadd($Info['ffv'],$number,5);
        return $Info;
    }
    public function up($Info)
    {
        $id = $Info['id'];
        $where = ['id'=>$id];
        $upArr = ['ffv_consume'=>$Info['ffv_consume'] ,'ffv'=>$Info['ffv']];
        $upnum = $this->uptable($upArr,$where,$this->tablename);

        //
        return $upnum;
    }

    public function calcffv($money)
    {
        //273 对应的是 0.19->改成 373 对应 0.19
        $number = bcdiv($money,0.373); //一共可以有几个上升点，取整
        $per = 0.00019;
        $per = 0.00027;
        $get = bcmul($per,$number,5); //可以增加的
        return $get;
    }
    
}

?>